#ifndef MAEMO5STATUSUPDATER_H
#define MAEMO5STATUSUPDATER_H

#include "istatusupdater.h"

#include "maemo5/maemo5qtprojectgenerator.h"

#define LASTLOG_ITEMS 10

// TODO factor out commonality with SymbanStatusUpdater to a base class
class Maemo5StatusUpdater : public IStatusUpdater
{
    Q_OBJECT

private:
    //
    // private members
    //
    Maemo5QtProjectGenerator &m_generator;

    // Progress variables
    int m_currentValue;
    int m_maximumValue;
    int m_phasesInAction;
    int m_logSize;
    bool m_indefinite;

    // Generation status
    QString m_statusText;
    GeneratorPhase m_phase;
    GeneratorPhase m_lastPhase;

    // Lastlog for checking log
    QString m_lastLog[LASTLOG_ITEMS];
    int m_lastLogCounter;


public:
    //
    // lifetime management
    Maemo5StatusUpdater(Maemo5QtProjectGenerator & generator,
                        QObject                   * parent = 0);
    virtual ~Maemo5StatusUpdater();


    //
    // public operators
    //
    virtual void updateGeneratorStatus(bool manualTrigger = true);
    virtual void setIndefiniteProgress(bool indefinite);
    virtual void setPhases(int phases);
    virtual void reset();

    virtual int maximumProgress();
    virtual int currentProgress();
    virtual QString statusText();
    virtual int logSize();
    virtual QFileInfo pkgFileInfo();


private slots:
    void increase(QString message);
    void start(GeneratorTarget target);
    void stop();

private:
    int phaseLength(GeneratorPhase phase);
};

#endif // MAEMO5STATUSUPDATER_H
